package com.yi.gostockgo.common;

import lombok.AllArgsConstructor;

import lombok.NoArgsConstructor;

/**
 * 基础信息类
 */
@AllArgsConstructor
@NoArgsConstructor
public class BaseMessage {

    public static final int SUCCESS = 1;
    public static final int WARN = 2;
    public static final int FAIL = 0 ;

    private int state ;
    private String msg ;
    private Object object ;

    public int getState() {
        return state;
    }

    public BaseMessage setState(int state) {
        this.state = state;
        return this ;
    }

    public String getMsg() {
        return msg;
    }

    public BaseMessage setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Object getObject() {
        return object;
    }

    public BaseMessage setObject(Object object) {
        this.object = object;
        return this ;
    }

    /**
     * 失败的消息
     * @return
     */
    public static BaseMessage getBaseFail(){
        return getBaseFail("FAIL");
    }

    public static BaseMessage getBaseFail(String msg){
        return new BaseMessage(FAIL,msg,null);
    }

    /**
     * 成功的消息
     * @return
     */
    public static BaseMessage getBaseSuccess(){
        return getBaseSuccess(null);
    }
    public static BaseMessage getBaseSuccess(Object data){
        return getBaseSuccess("SUCCESS", data);
    }
    public static BaseMessage getBaseSuccess(String msg, Object data){
        return new BaseMessage(SUCCESS,msg,data);
    }

}
